/*
** event.c for Event in /home/vriely/Dropbox/work/Unix/Zappy_rendu/serv-src
**
** Made by Samuel Vrielynck
** Login   <vriely_s@epitech.net>
**
** Started on  Thu Jun 14 15:09:21 2012 Samuel Vrielynck
** Last update Thu Jul 19 18:15:55 2012 pierrick druart
*/

#include		<stdlib.h>

#include		"server.h"

t_expulse		*new_expulse(t_client *client)
{
  t_expulse		*expulse;

  expulse = (struct s_expulse *)malloc(sizeof(t_expulse));
  if (expulse != NULL)
    expulse->client = client;
  return (expulse);
}

t_event			*new_event(e_event type, long unsigned int action,
    void *data)
{
  t_event		*event;

  event = (t_event *)malloc(sizeof(t_event));
  if (event != NULL)
  {
    event->type = type;
    event->action = action;
    event->data = data;
  }
  return (event);
}

t_broadcast		*new_broadcast(t_coord coord, char *msg,
    t_client *client)
{
  t_broadcast		*broadcast;

  broadcast = (struct s_broadcast *)malloc(sizeof(t_broadcast));
  if (broadcast != NULL)
  {
    broadcast->coord = coord;
    broadcast->message = msg;
    broadcast->client = client;
  }
  return (broadcast);
}

t_incantation		*new_incantation(t_coord coord, unsigned char lvl_inca,
    t_client *client, unsigned char ok)
{
  t_incantation		*incan;

  incan = (struct s_incantation *)malloc(sizeof(t_incantation));
  if (incan != NULL)
  {
    incan->coord = coord;
    incan->lvl = lvl_inca;
    incan->client = client;
    incan->ok = ok;
  }
  return (incan);
}

t_fork			*new_fork(t_coord coord, t_client *client)
{
  static int		id = 0;
  t_fork		*ffork;

  ffork = (struct s_fork *)malloc(sizeof(t_fork));
  if (ffork)
  {
    ffork->coord = coord;
    ffork->status = -1;
    ffork->client = client;
    ffork->id = id;
  }
  id++;
  return (ffork);
}
